
Common.registerSpecialDict('gift_item', function(){
	var result = DWR.syncCall("zhgjService.findGifts")
	
	var items = []
	var item
	for (var i=0;i<result.length;i++){
		var r = result[i];
		item = {}
		item.code = r[0];
		item.text = r[1];
		items.push(item);
	}
	return items
})

function TranClearing(){}

TranClearing.statDateType = function (){
		var form = Page.form;
		if (!form) return;
		var statType = Common.getRadioValue("statType");
	
		if(statType == Constants.CLEAR_STAT_DYNA){
			$("beginDateTD").style.display=''
			$("endDateTD").style.display=''
			$("statDateTD").style.display='none'
			form.beginDate.value = TX.Misc.getDateBefore(1);
			form.endDate.value = TX.Misc.getDateBefore(1);
		
			return false;
		}else if(statType == Constants.CLEAR_STAT_DAY ){
			form.statDate.value = TX.Misc.getDateBefore(1);
			
			$("beginDateTD").style.display='none'
			$("endDateTD").style.display='none'
			$("statDateTD").style.display=''
		
		}else if(statType == Constants.CLEAR_STAT_MONTH){
			form.statDate.value = TX.Misc.getDateBefore(1);
			 $("beginDateTD").style.display='none'
			 $("endDateTD").style.display='none'
			  $("statDateTD").style.display=''
			
		}else if(statType == Constants.CLEAR_STAT_YEAR){
			form.statDate.value = TX.Misc.getDateBefore(1);
			 $("beginDateTD").style.display='none'
			 $("endDateTD").style.display='none'
			 $("statDateTD").style.display=''
		}
		return true;
}

var Page = {};

TranClearing.formatStatDate = function (){
		var form = Page.form;
		if (!form) return;
		var statType = Common.getRadioValue("statType");
	
		if(statType == Constants.CLEAR_STAT_DYNA){
			if(!checkTimeOrder(form.beginDate,form.endDate))
			return false;
		}else if(statType == Constants.CLEAR_STAT_DAY ){
			var sDate = form.statDate.value;
			form.beginDate.value = Format.getBeginTimeOfDay(sDate);
			form.endDate.value = Format.getEndTimeOfDay(sDate);
			
		}else if(statType == Constants.CLEAR_STAT_MONTH){
			var sDate = form.statDate.value;
			form.beginDate.value = Format.getBeginTimeOfMonth(sDate);
			form.endDate.value = Format.getEndTimeOfMonth(sDate);
			 
		}else if(statType == Constants.CLEAR_STAT_YEAR){
			var sDate = form.statDate.value;
			form.beginDate.value = Format.getBeginTimeOfYear(sDate);
			form.endDate.value = Format.getEndTimeOfYear(sDate);
		}
		return true;
}

TranClearing.initTranClearingStat = function(divid){
	Rpc.loadPage(divid,"/common/report/tranClearing_div.html",function(){
		Page.form = $("statForm");		
		Eui.initBeginDateInput("beginDateTd","起始日期","statForm","beginDate","endDate","_pastDate",true);
		Eui.initEndDateInput("endDateTd","结束日期","statForm","beginDate","endDate","_pastDate",true);
		Eui.initDateInput("statDateTd","统计日期","statForm","statDate","_pastDate",true)
		TranClearing.statDateType()
		});
}